package com.coscon.service.impl;

import com.coscon.mapper.*;
import com.coscon.service.DbInitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


/**
 * 初始化所以表，数据库列，初始数据等
 */
@Slf4j
@Service
public class DbInitServiceImpl implements DbInitService {

    @Resource
    private FilePathLogMapper testTableMapper;
    @Resource
    private FileDeleteLogMapper fileDeleteLogMapper;
    @Resource
    private FilePlayLogMapper filePlayLogMapper;
    @Resource
    private CmdExecLogMapper cmdExecLogMapper;
    @Resource
    private LoginLogMapper loginLogMapper;
    @Resource
    private SysConfigMapper configMapper;
    @Resource
    private WakeUpConfigMapper wakeUpConfigMapper;


    @Override
    @Transactional
    public void initSystemTables() {
        this.testTableMapper.createFilePathLogTable();
        this.fileDeleteLogMapper.createFileDeleteLogTable();
        this.filePlayLogMapper.createFilePlayLogTable();
        this.cmdExecLogMapper.createCmdExecLogTable();
        this.loginLogMapper.createLoginLogTable();
        this.configMapper.createSysconfigTable();
        this.wakeUpConfigMapper.createWakeUpConfigTable();
        //初始化配置数据
        this.configMapper.initSysConfigDataSecurityIsUser();
        this.configMapper.initSysConfigDataSecurityPasswordType();
        this.configMapper.initSysConfigDataSecurityCustomPassword();
    }

}
